vcTriangleSet
vcTriangleSet is a geometry set used for creating and storing a collection of triangles and tessellated surface data.
See in: Overview
Module: vcGeometry
Parent: vcGeometrySet
Children -
Referenced by: -
Properties
Learn how to use properties here. The properties are also inherited from the parent class.
| Name | Type | Access | Description |
| CreaseAngle | Real | R | Gets the angle tolerance for triangle See moreedge shading in which edge angles less than tolerance are rendered as smooth surfaces during light calculations. |
| PointCount | Integer | R | Gets the total number of points in set. |
| Points | list[vcVector] | RW | Gets or sets a positions in the form of an ordered list used for generating triangles of set.See moreIn order to generate triangles, position values should have a known index and be in XYZ order. For example, [123.0,45.0,4.5,15.0,45.0,90.0] would define the position of two points which are aligned on Y-axis. If the number of entries is not enough for all points in set, those points will be deleted from set as a clean up operation. If number is more than is needed for points, additional points are created in set. |
| TextureCoordinates | list[Real] | RW | Gets or sets list of texture coordinates for points in set.See moreIf the number of entries is not enough for all points in set, those points will be deleted from set as a clean up operation. If number is more than is needed for points, additional points are created in set. |
| Topology | vcTopology | R | Gets the container of topology data for points in set. |
| TriangleCount | Integer | R | Gets the total number of triangles in set. |
| TriangleIndices | list[Integer] | RW | Gets or sets the triangle indices of a set, which is an ordered list of vertex indices for each triangle. |
| UseDynamicTextureCoordinates | Boolean | RW | Gets or sets the value that controls weather texture coordinates of set can be updated during simulation. |
| UseTextureCoordinates | Boolean | RW | Gets or sets the use of texture coordinates in set. |
Methods
Learn how to use methods here. The methods are also inherited from the parent class.
| Name | Return Type | Parameters | Description |
| addPoint | Integer | vcVector point | Adds a point to set, and then returns index of point in set.See moreParameters: vector (vcVector): Position for the point. Returns: index (int): Index for the point. |
| addPoint | Integer | Real x, Real y, Real z | Adds a point to set, and then returns index of point in set.See moreParameters: x (float): x coordinate for the vector. y (float): y coordinate for the vector. z (float): z coordinate for the vector. Returns: index (int): Index for the point. |
| addTriangle | Integer | Integer pointIndex1, Integer pointIndex2, Integer pointIndex3 | Adds a triangle to set, and then returns new triangle count of set. See Example: Create sphere with triangle sets for more information.See moreParameters: pointIndex1 (int): Vertex index for the first vertex. pointIndex2 (int): Vertex index for the second vertex. pointIndex3 (int): Vertex index for the third vertex. Exceptions: IndexError: Index out of bounds. Returns: triangleIndex (int): Index for the triangle. |
| collapsePoint | None | Integer indexPoint1, Integer indexPoint2 | Collapses a point at a given index into another point at a given index in set, thereby updating triangles referencing first point to now reference second point.See moreGenerally, this is used to clean up redundant vertices, reduce data count or simplify geometry. Parameters: indexPoint1 (int): Index of the first point. indexPoint2 (int): Index of the second point. Exceptions: IndexError: Index out of bounds. |
| convexHull | vcTriangleSet | Boolean value | Creates a convex hull from geometry of set.See moreParameters: value (bool): If true, returns a new triangle set containing the resultant geometry. Otherwise, modifies the current geometry of set and returns the same set. Returns: vcTriangleSet: The convex hull set. |
| decimate | Real | Real quality, Real maxError | Simplifies triangles of set by merging points within a given maxError tolerance until a given quality level is achieved or tolerance is exceeded.See moreParameters: quality (float): Decimation quality percentage. Value between [0, 100]. A quality of N% means that (100 - N)% reduction will be done on the mesh. maxError (float): Decimation tolerance. Returns: float: Reduction Percentage. Percentage of triangles removed. |
| decompose | None | None | Regroups triangles in set into different sets based on the connection of each triangle to one another. |
| deleteTriangle | None | Integer triangleIndex | Deletes a triangle at a given index in set.See moreYou should call the update() method after deleting one or more triangles from set. Parameters: triangleIndex (int): Index of the triangle to delete. Exceptions: IndexError: Index out of bounds. |
| getPoint | vcVector | Integer pointIndex | Returns the position vector of point at a given index in set.See moreParameters: pointIndex (int): Index for the point. Exceptions: IndexError: Index out of bounds. Returns: vcVector: Position vector. |
| getPointIndicesWithin | list[Integer] | vcVector position, Real sideLength | Returns a list of indices for points in set within an area defined by a given position and sideLength.See moreParameters: position (vcVector): Reference point position. sideLength (float): Search area side length. Exceptions: LicenseError: No license for Robotics API. Returns: list[int]: list of integer point indices. |
| getPointIndicesWithin | list[Integer] | vcVector position, Real sideLength, vcVector normal | Returns a list of indices for points in set within an area defined by a given position and sideLength. A normal argument can be given to filter points with the same surface normal. See moreParameters: position (vcVector): reference point position. sideLength (float): Search area side length. normal (vcVector): Search area normal vector. Exceptions: LicenseError: No license for Robotics API. Returns: list[int]: list of integer point indices. |
| getPointNormals | list[vcVector] | List[Integer] indices, Optional Keyword[convert = vcMatrix] | Returns a list of surface normal vectors for points at a given list of indices in set.See moreA convert argument can be used to transform each vector by a given matrix. Parameters: indices (list[int]): List of integer indices. Optional: convert (vcMatrix): Matrix for converting normals. Exceptions: IndexError: Index out of bounds. LicenseError: No license for Robotics API. Returns: list[vcVector]: List of vcVector normals. |
| getPointPositions | list[vcVector] | List[Integer] indices, Optional Keyword[convert = vcMatrix] | Returns a list of position vectors for points at a given list of indices in set.See moreA convert argument can be used to transform each vector by a given matrix. Parameters: indices (list[int]): List of integer indices. Optional: convert (vcMatrix): Matrix for converting positions. Exceptions: IndexError: Index out of bounds. LicenseError: No license for Robotics API. Returns: list[vcVector]: List of vcVector positions. |
| getTextureCoordinate | tuple[Real, Real] | Integer index | Gets an ordered pair of UV coordinates for the point at the given index.See moreParameters: index (int): Texture coordinate index. Exceptions: IndexError: Index out of bounds. Returns: tuple[float, float]: 2-tuple (float u, float v) texture coordinate. |
| getTextureCoordinates | list[tuple[Real, Real]] | List[Integer] indices | Gets a list containing an ordered pair of UV coordinates for points at given indices in set.See moreParameters: indices (list): List of integer indices Exceptions: IndexError: Index out of bounds. LicenseError: No license for Robotics API. Returns: list[tuple[float, float]]: List of 2-tuple (float u, float v) texture coordinates. |
| getTriangle | tuple[Integer, Integer, Integer] | Integer triangleIndex | Returns the indices of vertices for a triangle at a given index in set.See moreParameters: triangleIndex (int): Index for the triangle. Exceptions: IndexError: Index out of bounds. Returns: tuple[int, int, int]: (int pointIndex1, int pointIndex2, int pointIndex3) |
| getTriangleEdgeNeighbor | tuple[Integer, Integer] OR None | Integer index, Integer vertex | Returns the index of a triangle neighboring another triangle at a given index and vertex in set.See moreThe returned value is an ordered pair identifying neighboring triangle and shared vertex in set. Parameters: index (int): Triangle index. vertex (int): Vertex number. Should be either 0, 1 or 2. Exceptions: IndexError: Index out of bounds. Returns: tuple[int, int]: (int triangleIndex, int vertexIndex) |
| getTriangleEdgeType | vcEdgeType | Integer index, Integer vertex | Returns the type of edge for a triangle at a given index and vertex in set.See moreParameters: index (int): Triangle index. vertex (int): Vertex number. Should be either 0, 1 or 2. Exceptions: IndexError: Index out of bounds. Returns: vcEdgeType: Edge type. |
| getTriangleNormal | vcVector | Integer triangleIndex | Returns the surface normal of a triangle at a given index in set.See moreParameters: triangleIndex (int): Index for the triangle. Exceptions: IndexError: Index out of bounds. Returns: vcVector: Normal vector. |
| mergePoints | None | Real tolerance, Optional Keyword[onlyBoundaryPoints = Boolean] | Merges points of triangles within a given tolerance that are not connected to one another by adding lines.See moreParameters: tolerance (float): Merge tolerance. Optional: onlyBoundaryPoints (bool): This argument can be used to only merge points that border one another and that are within the given tolerance. |
| setCreaseAngle | None | Real creaseAngle | Sets the angle tolerance for triangle edge shading in which edge angles less than tolerance are rendered as smooth surfaces during light calculations. Parameters: creaseAngle (float): New value for the crease angle. |
| setPoint | None | Integer pointIndex, vcVector point | Sets the position vector of a point at a given index in set.See moreParameters: pointIndex (int): Index for the point. point (vcVector): Position for the point. Exceptions: IndexError: Index out of bounds. |
| setTextureCoordinate | None | Integer textureCoordinateIndex, Real u, Real v | Sets the texture coordinates of a point at a given index in set.See moreParameters: textureCoordinateIndex (int): Index for the coordinate. u (float): horizontal coordinate. v (float): vertical coordinate. Exceptions: IndexError: Index out of bounds. |
| setTextureCoordinates | None | List[Integer] indices, List[tuple[Real, Real]] textureCoordinates | Sets the texture coordinates of points at a given list of indices in set.See moreParameters: indices (list[int]): List of integer indices textureCoordinates (list[tuple[float, float]]): List of 2-tuple (float u, float v) coordinates. Exceptions: LicenseError: No license for Modeling API. ValueError: Size for the indices and texture coordinates do not match. |
| setTriangle | None | Integer triangleIndex, Integer pointIndex1, Integer pointIndex2, Integer pointIndex3 | Sets the vertex indices of a triangle at a given index in set.See moreParameters: triangleIndex (int): index of the triangle. pointIndex1 (int): Vertex index for triangles first vertex. pointIndex2 (int): Vertex index for triangles second vertex. pointIndex3 (int): Vertex index for triangles third vertex. Exceptions: IndexError: Index out of bounds. |
| subdivide | None | Real maxEdgeLength, Optional Keyword[maxTriangles = Integer] | Modifies triangles in set into smaller triangles with edge lengths smaller or equal to a given maxEdgeLength.See moreA maxTriangles argument can be given to stop subdivision when triangle count reaches a maximum limit. Parameters: maxEdgeLength (float): Edge length limit. Optional: maxTriangles (int): Triangle count limit. |
| update | None | None | Updates the set and its bound box. |
Example: Create Sphere with Triangle Sets
''' vcTriangleSet: Create sphere with triangle sets ''' import vcCore as vc import vcFeatures as vc_fea vc_ft = vc_fea.vcFeatureType import vcGeometry as vc_geo vc_gst = vc_geo.vcGeometrySetType app = vc.getApplication() comp = vc.getComponent() geometry = comp.findFeature("Geometry") if not geometry: geometry = comp.RootFeature.create(vc_ft.GEOMETRY, "Geometry") geometry.Geometry.clear() triangle_set = geometry.Geometry.createGeometrySet(vc_gst.TRIANGLE_SET) radius_vector = vc.vcVector.new(100.0, 0.0, 0.0) matrix = vc.vcMatrix.new() for i in range(0,361,15): # Step every 15 degrees around Z (first and last coincident) for j in range(90,-91,-15): # Half circle in 12 sections around Y, # starting from south pole matrix.identity() # always reset the origin before rotate matrix.rotateRelZ(i) matrix.rotateRelY(j) p = matrix * radius_vector # transform the radius vector with reoriented origin triangle_set.addPoint(p) for i in range(26): # i is the section around Z (12 in each) for j in range(12): # is around the rotating y axis triangle_set.addTriangle(i*12+j,(i+1)*12+j,(i+1)*12+j+1) triangle_set.addTriangle(i*12+j+1,i*12+j,(i+1)*12+j+1) geometry.rebuild() comp.update() app.render()